package games.platformer.behaviors;

import games.platformer.Level;
import vooga.core.Sound;
import vooga.core.Player;

/**
 * When the PlayerCharacter runs into the ExitDoor and there are no more DoorKeys left, go to the next level
 * and give the Player some points for finishing the level
 * 
 * @author Jonathan Odom
 * @author bshelton
 */
public class IntersectAndWinLevel extends Intersect
{
	final static int POINTS_LEVEL = 1000;
	private Level myLevel;
	private Sound mySound;
	private Player myPlayer;
	
    public IntersectAndWinLevel (vooga.geom.Vector velocity,
    		vooga.entities.Entity obstacle, Level level, String sound, Player player)
    {
        super(velocity, obstacle);
        myLevel = level;
        mySound = new Sound(sound);
        myPlayer = player;
    }

    public IntersectAndWinLevel (vooga.geom.Vector velocity,
                               java.util.List<vooga.entities.Entity> obstacles, Level level, String sound, Player player)
    {
        super(velocity, obstacles);
        myLevel = level;
        mySound = new Sound(sound);
        myPlayer = player;
    }
    
    public IntersectAndWinLevel (vooga.geom.Vector velocity,
            java.util.Collection<vooga.entities.Entity> obstacles, Level level, String sound, Player player)
    {
    	super(velocity, obstacles);
    	myLevel = level;
    	mySound = new Sound(sound);
    	myPlayer = player;
	}


    protected void onCollide (vooga.entities.Entity lhs, vooga.entities.Entity rhs)
    {
        if(myLevel.getDoorKeys().isEmpty())
        {
        	myPlayer.getStatus().addScore(POINTS_LEVEL);
        	mySound.play();
        	myLevel.toNextLevel();
        }
    }
}
